package com.coder4j.controller;

import com.coder4j.entity.SDisplayInterfaceDetailEntity;
import com.coder4j.service.SDisplayInterfaceDetailService;
import com.coder4j.vo.SDisplayInterfaceDetailQuery;
import com.coder4j.vo.SDisplayInterfaceDetailVO;
import com.coder4j.starter.mybatis.BasePage;
import com.coder4j.starter.web.R;
import com.coder4j.utils.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * 显示界面兴趣区详情
 * @author keller
 * @date 2025-03-18 16:22:26
 */
@Slf4j
@RestController
@RequestMapping("/sDisplayInterfaceDetail")
public class SDisplayInterfaceDetailController {
    @Resource
    private SDisplayInterfaceDetailService service;

    @Resource
    private HttpServletResponse response;

    /**
     * 按ID查询显示界面兴趣区详情
     * @param id SDisplayInterfaceDetail.id
     * @return 显示界面兴趣区详情对象
     */
    @GetMapping("/getById")
    public R<SDisplayInterfaceDetailVO> getById( Long id){

        return R.success(service.baseGetVOById(id));
    }

    /**
     * 保存显示界面兴趣区详情
     * 有 id 字段，更新；否则新增
     * @param sDisplayInterfaceDetail SDisplayInterfaceDetail对象
     * @return SDisplayInterfaceDetail对象
     */
    @PostMapping("/save")
    public R save(@RequestBody SDisplayInterfaceDetailVO sDisplayInterfaceDetail){


        service.baseSaveVO(sDisplayInterfaceDetail);
        return R.success();
    }

    /**
     * 查询列表
     * @param query 查询条件
     * @return 数据列表
     */
    @PostMapping("/page")
    public R<BasePage<SDisplayInterfaceDetailVO>> getList(@RequestBody SDisplayInterfaceDetailQuery query){
        if(query == null){
            query = new SDisplayInterfaceDetailQuery();
        }
        return R.success(service.baseQueryVOPage(query));
    }

    /**
     * 删除显示界面兴趣区详情
     * 如果Entity继承了 BaseSoftDeleteEntity，使用逻辑删除；否则，使用物理删除
     * @param id SDisplayInterfaceDetail.id
     * @return 删除的数据
     */
    @PostMapping("/deleteById")
    public R deleteById( Long id){
        service.baseDeleteById(id);
        return R.success();
    }
}
